<include file="Public/header" />
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>相册管理</h3>
      <ul class="tab-base">
        <li><a href="{:U('Album/album')}"><span>管理</span></a></li>
        <li><a href="JavaScript:void(0);" class="current"><span>新增</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="album_add_form" method="post" action="{:U('Album/album_add')}">
    <input type="hidden" name="form_submit" value="ok" />
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="aclass_name">相册名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="aclass_name" id="aclass_name" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>

        <tr>
          <td colspan="2" class="required"><label>排序:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="0" name="aclass_sort" id="aclass_sort" class="txt"></td>
          <td class="vatop tips">数字范围为0~255，数字越小越靠前</td>
        </tr>
      </tbody>
      <tfoot>
        <tr>
          <td colspan="2"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span>提交</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script>
//按钮先执行验证再提交表单
$(function(){

	$("#submitBtn").click(function(){
		if($("#album_add_form").valid()){
			$("#album_add_form").submit();
		}
	});
	
	$('#album_add_form').validate({
        errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        success: function(label){
            label.addClass('valid');
        },
        rules : {
            aclass_name : {
                required : true
            },
            aclass_sort : {
                number   : true
            }
        },
        messages : {
            aclass_name : {
                required : '名称不能为空'
			},
            aclass_sort  : {
                number   : '排序仅能为数字'
            }
        }
    });
	
});
</script>
<include file="Public/footer" />